<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${class.id == null ? '创建班级' : '编辑班级'} + ' - 智能教育系统'"></title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            margin: 0;
            padding-top: 80px;
        }

        .form-container {
            max-width: 600px;
            margin: 2rem auto;
            padding: 2rem;
            background: white;
            border-radius: 20px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-control {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 2px solid #e2e8f0;
            border-radius: 10px;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: #6e8efb;
            box-shadow: 0 0 0 3px rgba(110,142,251,0.2);
            outline: none;
        }

        .btn-primary {
            width: 100%;
            padding: 0.75rem;
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            border: none;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(110,142,251,0.4);
        }

        .alert {
            padding: 1rem;
            border-radius: 10px;
            margin-bottom: 1rem;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from {
                transform: translateY(-10px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
    </style>
</head>
<body>
    <!-- 引入导航栏 -->
    <div th:replace="fragments/navbar :: navbar"></div>

    <div class="form-container">
        <h2 class="text-2xl font-bold text-center mb-6" 
            th:text="${class.id == null ? '创建新班级' : '编辑班级'}"></h2>
        
        <!-- 错误消息 -->
        <div th:if="${error}" class="alert bg-red-100 text-red-700" th:text="${error}"></div>

        <form th:action="${class.id == null ? '/class/create' : '/class/edit/' + class.id}" 
              method="post" 
              th:object="${class}">
            
            <div class="form-group">
                <label class="block text-gray-700 mb-2">班级名称</label>
                <input type="text" 
                       th:field="*{className}" 
                       class="form-control" 
                       required>
            </div>
            
            <div class="form-group">
                <label class="block text-gray-700 mb-2">年级</label>
                <select th:field="*{grade}" class="form-control" required>
                    <option value="">请选择年级</option>
                    <option value="一年级">一年级</option>
                    <option value="二年级">二年级</option>
                    <option value="三年级">三年级</option>
                    <option value="四年级">四年级</option>
                    <option value="五年级">五年级</option>
                    <option value="六年级">六年级</option>
                    <option value="初一">初一</option>
                    <option value="初二">初二</option>
                    <option value="初三">初三</option>
                    <option value="高一">高一</option>
                    <option value="高二">高二</option>
                    <option value="高三">高三</option>
                </select>
            </div>
            
            <div class="form-group">
                <label class="block text-gray-700 mb-2">班级描述</label>
                <textarea th:field="*{description}" 
                          class="form-control" 
                          rows="3"></textarea>
            </div>
            
            <button type="submit" class="btn-primary">
                <span th:text="${class.id == null ? '创建班级' : '保存修改'}"></span>
            </button>
        </form>
    </div>
</body>
</html> 